<%@ page language="java" %>
<%
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("max-age", 0);
    response.setDateHeader("Expires", 0);
%>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.commons.SessionKeys"%>
<%@ page import="com.scalar.chiptrack.utils.StringUtils" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<html>

<HEAD>
	<TITLE>ScalarSoft - ChipTrac - Forecast analysis view and compare </TITLE>
    <META http-equiv='Content-Type' content='text/html; charset=windows-1252'>
    <LINK href='<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css' type='text/css' rel='stylesheet'>
	<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
    <script type="text/javascript">
        function onScreenLoad() {

        }
        function viewReport(reportType, reportName) {
            var form = document.salesForecastReportForm;
            form.action = "<%=chipTracContext%>/forecastActualReport.do?action=forecastAnalysisView&reporttype="+reportType+"&reportname="+reportName;
            form.submit();
        }
        var reporttype1;
        var reporttype2;
        var reportname1 = "";
        var reportname2 = "";

        function assignreportforcompare(checkboxctrl, reporttype, reportname) {
            var errorsCtrl = document.getElementById("errors");
            errorsCtrl.innerHTML = "";
            if(checkboxctrl.checked) {
                if(reportname1 != "" && reportname2 != "") {
                    errorsCtrl.innerHTML = "<li>Already two reports are selected to compare. Please uncheck and select";
                    checkboxctrl.checked = false;
                    return;
                }
                if(reportname1 == "") {
                    reporttype1 = reporttype;
                    reportname1 = reportname;
                } else {
                    reporttype2 = reporttype;
                    reportname2 = reportname;
                }
            } else {
                if(reportname1 == reportname) {
                    reportname1 = "";
                    reporttype1 = "";
                } else {
                    reportname2 = "";
                    reporttype2 = "";
                }
            }

        }
        function compareReports() {
            var form = document.salesForecastReportForm;
            var errorsCtrl = document.getElementById("errors");
            errorsCtrl.innerHTML = "";
            if(reportname1 == "" || reportname2 == "") {
                errorsCtrl.innerHTML = "<li>Please select two reports to compare";
            } else {
                form.action = "<%=chipTracContext%>/forecastActualReport.do?action=compareForecastAnalysis&reporttype1="+reporttype1+"&reportname1="+reportname1+"&reporttype2="+reporttype2+"&reportname2="+reportname2;
                form.submit();
            }
        }
    </script>
</HEAD>

<BODY bgcolor='ffffff' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0' onload="javascript:onScreenLoad()">

<html:form name="salesForecastReportForm" type="com.scalar.forecast.forecastReports.forms.SalesForecastReportForm" action="/forecastActualReport.do?action=forecastAnalysisViewAndCompare">

<table align='center' border='0' width='100%'>
    <tr>
        <td colspan='4' align='center' class="NArialL">Forecast Analysis View and Compare Reports</td>
    </tr>
    <tr>
        <td colspan='4' class="NArialL">
            <FONT id="errors" color='FF0000'></font>
            <chiptrack:errors styleClass="NArialL"/>
            <chiptrack:info styleClass="NArialL"/>
        </td>
    </tr>
        <%--<tr>
            <td class='NArialL' width="50%">Wafer Map/Inked:</td>
            <td class='NArialL'>
                <html:select name="assmReleaseForm" property="waferMapOrInkedForBom" styleClass="txfield">
                    <html:options property="waferMapOrInkedList"/>
                </html:select>
            </td>
            <td colspan='2'>&nbsp;</td>
        </tr>--%>
    <tr>
        <td colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td>
    </tr>
</table>
<table border="0" width="55%" align="center">
    <tr class="NArialL">
        <td colspan="5" align="right" class="NArialL"><a href="javascript:compareReports();">Compare</a></td>
    </tr>
    <tr class="NArialL">
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
            Report Name
        </font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
            Scenario</font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
           Report Type</font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
           Report Date</font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
            Actions</font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Select</font>
        </td>
    </tr>
    <logic:iterate name="analysisReportsList" id="analysisReport"
                   type="com.scalar.forecast.forecastReports.AnalysisReport" indexId="index">

        <tr class="NArialL">
            <td align="center" bgcolor="#D8D8D8" class="NArialL">
                <bean:write name="analysisReport" property="reportName"/>
            </td>
            <td align="center" bgcolor="#D8D8D8" class="NArialL">
                <bean:write name="analysisReport" property="scenario"/>
            </td>
            <td align="center" bgcolor="#D8D8D8" class="NArialL">
                <bean:write name="analysisReport" property="reprotType"/>
            </td>
            <td align="center" bgcolor="#D8D8D8" class="NArialL">
                <%=StringUtils.formatDateToString(analysisReport.getTimestamp())%>                
            </td>
            <td align="center" bgcolor="#D8D8D8" class="NArialL" nowrap><a href="javascript:viewReport('<bean:write name="analysisReport" property="reprotType"/>','<bean:write name="analysisReport" property="reportName"/>')">View</a> &nbsp;<%--|&nbsp; <a
                    href="#">Delete</a>--%></td>
            <td align="center" bgcolor="#D8D8D8" class="NArialL"><input type="checkbox" class="txfield" value="#" onclick="javascript:assignreportforcompare(this,'<bean:write name="analysisReport" property="reprotType"/>','<bean:write name="analysisReport" property="reportName"/>')"/></td>
        </tr>

    </logic:iterate>
</table>
</html:form>
</body>
</html>